document.addEventListener('DOMContentLoaded', function () {
    // 初始化地图
    if (document.getElementById('food-map')) {
        const map = L.map('food-map').setView([24.9097, 118.684], 14); // 泉州中心坐标
        L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
            attribution: '&copy; OpenStreetMap 贡献者'
        }).addTo(map);

        // 添加几个美食点位标记
        L.marker([24.9097, 118.684]).addTo(map)
            .bindPopup("开元寺旁面线糊");
        L.marker([24.9150, 118.6900]).addTo(map)
            .bindPopup("中山路润饼");
        L.marker([24.9200, 118.7000]).addTo(map)
            .bindPopup("钟楼汤圆摊");
    }

    // 筛选功能
    const typeFilter = document.getElementById('typeFilter');
    const cards = document.querySelectorAll('.food-cards .card');

    if (typeFilter) {
        typeFilter.addEventListener('change', function () {
            const selectedType = this.value;

            cards.forEach(card => {
                const cardType = card.getAttribute('data-type');
                if (!selectedType || cardType === selectedType) {
                    card.style.display = 'block';
                } else {
                    card.style.display = 'none';
                }
            });
        });
    }
});